package com.ruoyi.web.controller.mobile;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.mobile.domain.HuaweiHealthWeekStat;
import com.ruoyi.mobile.model.vo.HuaweiHealthWeekStatVo;
import com.ruoyi.mobile.service.IHuaweiHealthWeekStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 华为健康每周统计数据Controller
 * 
 * @author ruoyi
 * @date 2022-10-18
 */
@RestController
@RequestMapping("/mobile/weekstat")
public class HuaweiHealthWeekStatController extends BaseController
{
    @Autowired
    private IHuaweiHealthWeekStatService huaweiHealthWeekStatService;

    /**
     * 查询华为健康每周统计数据列表
     */
    @PreAuthorize("@ss.hasPermi('mobile:weekstat:list')")
    @GetMapping("/list")
    public TableDataInfo list(HuaweiHealthWeekStat huaweiHealthWeekStat)
    {
        startPage();
        List<HuaweiHealthWeekStat> list = huaweiHealthWeekStatService.selectHuaweiHealthWeekStatList(huaweiHealthWeekStat);
        return getDataTable(list);
    }

    /**
     * 导出华为健康每周统计数据列表
     */
    @PreAuthorize("@ss.hasPermi('mobile:weekstat:export')")
    @Log(title = "华为健康每周统计数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HuaweiHealthWeekStat huaweiHealthWeekStat)
    {
        List<HuaweiHealthWeekStatVo> list = huaweiHealthWeekStatService.selectHuaweiHealthWeekStatVoList(huaweiHealthWeekStat);
        ExcelUtil<HuaweiHealthWeekStatVo> util = new ExcelUtil<HuaweiHealthWeekStatVo>(HuaweiHealthWeekStatVo.class);
        util.exportExcel(response, list, "华为健康每周统计数据数据");
    }


    /**
     * 导出华为健康每周统计数据列表
     */
    @PreAuthorize("@ss.hasPermi('mobile:weekstat:exportLastWeek')")
    @Log(title = "华为健康上一周统计数据", businessType = BusinessType.EXPORT)
    @PostMapping("/exportLastWeek")
    public void exportLastWeek(HttpServletResponse response)
    {
        List<HuaweiHealthWeekStatVo> list = huaweiHealthWeekStatService.selectHuaweiHealthLastWeekStatVoList();
        ExcelUtil<HuaweiHealthWeekStatVo> util = new ExcelUtil<HuaweiHealthWeekStatVo>(HuaweiHealthWeekStatVo.class);
        util.exportExcel(response, list, "华为健康上周统计数据数据");
    }

}
